package com.hutao.medical.common.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {

	
	/**
	 * 获取当天最小时间 00:00:00
	 * @param date
	 * @return
	 * @throws ParseException
	 */
	public static Date getMinDayTime(Date date) {
		Date minTime=null;
		try {
			
			SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd 00:00:00");
			String formatStr = format.format(date);
			System.out.println(formatStr);
			minTime = format.parse(formatStr);
		} catch (Exception e) {
			// TODO: handle exception
		}
		return minTime;
	}
	
	
	/**
	 * 获取当天最大时间 23:59:59
	 * @param date
	 * @return
	 * @throws ParseException
	 */
	public static Date getMaxDayTime(Date date){
		Date maxTime=null;
		try {
		SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd 23:59:59");
		String formatStr = format.format(date);
		System.out.println(formatStr);
		maxTime = format.parse(formatStr);
		} catch (Exception e) {
			// TODO: handle exception
		}
		return maxTime;
	}
	
	
	public static Date strToDate(String dateStr){
		Date date=null;
		try {
			SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
			date = format.parse(dateStr);
		} catch (Exception e) {
			// TODO: handle exception
		}
		return date;
	}
	
	
	public static String  dateToStr(Date date){
		String str=null;
		try {
			SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
			str = format.format(date);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return str;
	}
	

	
	
}
